package com.lq.ecoldchain.ui.main.message

import com.lq.ecoldchain.base.viewmodel.BaseViewModel
import com.lq.ecoldchain.entity.Message
import com.lq.ecoldchain.entity.MessageBean
import com.lq.ecoldchain.internet.BaseObserver

/*
*2018/12/27 0027  18:59
*function by lq
*/
class MessageViewModel:BaseViewModel(){
    val list by lazy { ArrayList<Message>() }
    init {
        obtainMessageData()
    }

    private fun obtainMessageData(){
        BaseNetCore.ApiServiceImpl.obtainMsgList(1,10).compose(RxTransformer.switchSchedulers()).subscribe(object:BaseObserver<MessageBean>(){
            override fun onSuccess(t: MessageBean?) {
                if(t!=null && !t.list.isNullOrEmpty()){
                    list.clear()
                    list.addAll(t.list)
                }
            }

            override fun onFail(code: String) {}
        })
    }

}